<?php
/**
* File : WrapableGenerator.php
* Created by Ludovic Reenaers
* Created on  24 nov. 2010
* lreenaers@hotmail.com
*/
class WrapableGenerator extends Generator implements Wrapable{
	protected $children = array();
	public function setChildren($childArray){
		$bool = true;
		foreach ($childArray as $child){
			if (!is_a( $child, "Generator")){
				$bool = false;
			}
		}
		if($bool){
			$this->children = $childArray;
		}else{
			throw new Exception ("Array must only contains Generators.!");
		}
	}
	public function getChildren(){
		return $this->children;
	}
	public function addChild($Child){
		if (is_a($Child, "Generator")){
			array_push($this->children, $Child);
		}else{
			throw new Exception("you can only add Generators.");
		}
	}
	function dump(){
		$this->setUp();
		$wraped = "";
			
		foreach ($this->children as $child){

			$wraped.=$child->dump();
		}
		return str_replace("{WRAP-HERE}",$wraped,$this->content);
	}
}
?>